package com.example.fuckumusic.fragment;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.fuckumusic.R;
import com.example.fuckumusic.login.LoginPage;

public class LeftFragment extends Fragment {

	private TextView scoreTxt, score, nickName;

	private Button loginBtn, registBtn;

	private ImageView backImg, avatar;

	private View view;

	private String mBundle;

	private static final String ARGUMENT = "argument";

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Bundle bundle = getArguments();
		System.out.println(bundle);
	}

	public static LeftFragment newInstance(String bundle) {
		return null;

	}

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);

	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		view = inflater.inflate(R.layout.layout_menu, null);
		findViews(view);

		score.setVisibility(View.INVISIBLE);
		scoreTxt.setVisibility(View.INVISIBLE);
		nickName.setVisibility(View.INVISIBLE);
		avatar.setVisibility(View.INVISIBLE);

		loginBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent();
				intent.setClass(getActivity(), LoginPage.class);
				startActivity(intent);

			}
		});

		// Intent intent = getActivity().getIntent();
		// UserInfo info = (UserInfo) intent.getSerializableExtra("User");
		// System.out.println(info);
		// String name = info.getName();
		// String nickname = info.getNickname();
		// if (nickname != null) {
		// nickName.setText(nickname);
		// nickName.setVisibility(View.VISIBLE);
		// score.setVisibility(View.VISIBLE);
		// scoreTxt.setVisibility(View.VISIBLE);
		//
		// avatar.setVisibility(View.VISIBLE);
		// loginBtn.setVisibility(View.INVISIBLE);
		// registBtn.setVisibility(View.INVISIBLE);
		//
		// }
		// Intent intent = new Intent();
		// String userTxt = intent.getStringExtra("username");
		// String nickNameTxt = intent.getStringExtra("nickname");
		// int path = intent.getIntExtra("imgpath", 0);
		// loginBtn.setVisibility(View.INVISIBLE);
		// registBtn.setVisibility(View.INVISIBLE);
		// nickName.setVisibility(View.VISIBLE);
		// avatar.setVisibility(View.VISIBLE);
		// nickName.setText(nickNameTxt);

		return view;
	}

	public void findViews(View view) {
		scoreTxt = (TextView) view.findViewById(R.id.info_score);
		score = (TextView) view.findViewById(R.id.math_score);
		nickName = (TextView) view.findViewById(R.id.info_nickname);
		loginBtn = (Button) view.findViewById(R.id.login_btn);
		registBtn = (Button) view.findViewById(R.id.regist_btn);
		backImg = (ImageView) view.findViewById(R.id.backgroud_img);
		avatar = (ImageView) view.findViewById(R.id.person_img);
	}

	@Override
	public void onDestroyView() {
		super.onDestroyView();
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
	}

}
